﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using Gift.DAL;
using Gift.Model;

namespace WebSite.admin.system
{
    public partial class updatePassword : BaseAdmin
    {
        readonly DALAdminLogin theAdminLogin = new DALAdminLogin();
        tbAdminlogin oAdminLogin;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSubmitForm1_Click(object sender, EventArgs e)
        {
            oAdminLogin = theAdminLogin.GetModelByAdminUser(base.AdminUser);
            if (oAdminLogin == null)
            {
                ExtAspNet.Alert.Show("登录超时，请重新登录！", "", "window.location.href='/admin/login.aspx'");
                return;
            }
            else
            {
                if (oAdminLogin.AdminPwd == FormsAuthentication.HashPasswordForStoringInConfigFile(re.replace(this.txtInitPassword.Text), "MD5"))
                {
                    oAdminLogin.AdminPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(re.replace(this.txtNewPassword.Text), "MD5");
                    theAdminLogin.Update(oAdminLogin);
                 
                    ExtAspNet.PageContext.RegisterStartupScript(ExtAspNet.ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    ExtAspNet.Alert.Show("旧密码不正确！");
                }
            }
        }


    }
}